﻿<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:s="http://www.codeplex.com/MSSqlSchemaDoc">
  
  <xsl:param name="DocumentationFile"/>

  <xsl:template match="s:Index">
    <xsl:variable name="IndexName" select="@Name"/>

    <tr class="center">
      <td class="tablePrimaryColumn">
        <xsl:value-of select="$IndexName"/>
      </td>

      <td>
        <xsl:value-of select="@Type"/>
      </td>
      <td>
        <xsl:value-of select="s:IsUnique"/>
      </td>
      <td>
        <xsl:value-of select="s:IgnoreDuplicateKey"/>
      </td>
      <td>
        <xsl:value-of select="s:IsPrimaryKey"/>
      </td>
      <td>
        <xsl:value-of select="s:IsUniqueConstraint"/>
      </td>
      <td>
        <xsl:value-of select="s:FillFactor"/>
      </td>
      <td>
        <xsl:value-of select="s:IsPadded"/>
      </td>
      <td>
        <xsl:value-of select="s:IsDisabled"/>
      </td>
      <td>
        <xsl:value-of select="s:IsHypothetical"/>
      </td>
      <td>
        <xsl:value-of select="s:AllowRowLocks"/>
      </td>
      <td>
        <xsl:value-of select="s:AllowPageLocks"/>
      </td>
      <td>
        <xsl:choose>
          <xsl:when test="s:HasFilter = 'true'">
            <xsl:value-of select="s:FilterDefinition"/>
          </xsl:when>
          <xsl:otherwise>
            No Filter
          </xsl:otherwise>
        </xsl:choose>
      </td>
      <td>
        <table width="100%">
          <xsl:for-each select="s:Columns/s:IndexColumn">
            <tr>
            <td>
              <xsl:value-of select="@Name"/>
            </td>
            <td>
              <xsl:choose>
                <xsl:when test="s:IsDecendingKey = 'false'">ASC</xsl:when>
                <xsl:otherwise>DESC</xsl:otherwise>
              </xsl:choose>
            </td>
            <td>
              <xsl:if test="s:IsIncludedColumn = 'true'">Included</xsl:if>
            </td>
          </tr>
          </xsl:for-each>
        </table>
      </td>
    </tr>
    <tr>
      <td colspan="14" class="documentation center">
        <pre>
          <xsl:value-of select="document($DocumentationFile)/s:TableDocumentation/s:Indexes/s:IndexDocumentation[@Name=$IndexName]/s:Documentation"/>
          <xsl:value-of select="document($DocumentationFile)/s:ViewDocumentation/s:Indexes/s:IndexDocumentation[@Name=$IndexName]/s:Documentation"/>
        </pre>
      </td>
    </tr>
    </xsl:template>
</xsl:stylesheet>